﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddTodayLotteryResult.aspx.cs"
    Inherits="LotteryVote.AddTodayLotteryResult" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="JS/jquery-1.5.1.min.js" type="text/javascript"></script>
    <script src="JS/comm.js" type="text/javascript"></script>
    <script src="JS/jquery-ui-1.8.18.custom.min.js" type="text/javascript"></script>
    <link href="Style/comm.css" rel="stylesheet" type="text/css" />
    <link href="Style/Commission.css" rel="stylesheet" type="text/css" />
    <link href="UI/start/jquery-ui-1.8.18.custom.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <h3>
        <%=GetGlobalResourceObject("Resource", "Add") + "" + GetGlobalResourceObject("Resource", "TodayLotteryCompany")%>
    </h3>
    <div>
        <asp:RadioButtonList ID="rbl_company" runat="server" RepeatDirection="Horizontal"
            RepeatLayout="Flow" AutoPostBack="true" OnSelectedIndexChanged="rbl_company_SelectedIndexChanged">
        </asp:RadioButtonList>
        <%if (NumLenSupportList != null)
          {%>
        <table id="lotteryNums">
            <% foreach (var support in NumLenSupportList)
               {%>
            <tr>
                <td>
                    <%=support.Length.LenName %>
                </td>
                <%for (int i = 0; i < support.Count; i++)
                  {%>
                <td>
                    <input type="text" maxlength='<%=support.Length.Length %>' class="number" />
                </td>
                <%} %>
            </tr>
            <%} %>
            <tr>
                <td colspan="2">
                    <asp:Button ID="btn_submit" runat="server" 
                        Text="<%$Resources:Resource,Submit %>" onclick="btn_submit_Click" />
                </td>
            </tr>
        </table>
        <%} %>
    </div>
    <asp:HiddenField ID="hd_companyValue" runat="server" />
    </form>
    <script type="text/javascript">
        $(document).ready(function () {
            $("input[type='submit']").bind("click", function () {
                setNum();
            });
            $(".number").blur(function () {
                var num = $(this).val();
                if (isNullOrEmpty(num)) return;
                var count = 0;
                $(".number").each(function (i, obj) {
                    if ($(obj).val() == num) count++;
                });
                if (count > 1) {
                    var msg = "存在多个" + num;
                    alert(msg);
                }
            }).numeral(true);
        });

        var setNum = function () {
            $("#<%=hd_companyValue.ClientID %>").val(getNumModel());
        }
        var getNumModel = function () {
            var numArr = new Array();
            $("#lotteryNums input[type='text']").each(function (i, obj) {
                obj = $(obj);
                var num = obj.val();
                if (isNaN(num))
                    throw new Error(num + "不是数字!");
                numArr.push("{\"PeriodId\":0,\"RecordId\":0,\"Value\":\"" + num + "\"}");
            });
            return "[" + numArr.join() + "]";
        }
    </script>
</body>
</html>
